<?php
namespace jy_weishop_en;
defined('BY_JYA') or exit('error');
/*
	一下商城基础的分销
*/
class fenxiao extends \plugin{
	//分享细节
	public function up_fenfee($shopset=array(),$goods=array()){
		if(!$_SESSION['fromuser'] || !$_SESSION['uid']){
			return false;
		}
		$isadd=pdo_getcolumn('jy_weishop_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'mid');
		if($isadd){
			return false;
		}
		if($goods['id']){
			$commissions=json_decode($goods['commissions'],true);
			if($commissions['fen_feetype'] && $commissions['fen_feenum']){
				model('core/member')->member_credit($_SESSION['fromuser'],'credit'.$commissions['fen_feetype'],$commissions['fen_feenum'],true,'jy_weishop','分享商品获得奖励');
			}elseif($shopset['fen_feetype'] && $shopset['fen_feenum']){
				model('core/member')->member_credit($_SESSION['fromuser'],'credit'.$shopset['fen_feetype'],$shopset['fen_feenum'],true,'jy_weishop','分享商城获得奖励');
			}
		}elseif($_RQ['action']!='goods.detail'){
			if($shopset['fen_feetype'] && $shopset['fen_feenum']){
				model('core/member')->member_credit($_SESSION['fromuser'],'credit'.$shopset['fen_feetype'],$shopset['fen_feenum'],true,'jy_weishop','分享商城获得奖励');
			}
		}
		$insert=array(
			'mid'=>$_SESSION['uid'],
			'uniacid'=>$_SESSION['uniacid'],
			'storeid'=>$storeid?:$_SESSION['storeid'],
			'area_agentid'=>$area_agentid?:$_SESSION['area_agentid'],
			'area_code'=>$area_code?:$_SESSION['area_code'],
			'createtime'=>TIMESTAMP,
		);
		$this->model('member')->register($insert);
		return false;
	}
}